<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习3:进度指示器</title>
    <script src="../../js/vue.js"></script>
    <style>
        .progress-container {
            width: 1100px;
            height: 20px;
            background-color: #f0f0f0;
        }

        .progress-bar {
            height: 20px;
            background-color: #4caf50;
        }
    </style>
</head>

<body>
    <div id="app">
        <h1>自动进度指示器</h1>
        <div class="progress-container">
            <div class="progress-bar" :style="{ width: progress + '%' }"></div>
        </div>

        <p>当前进度: {{ progress }}%</p >
    </div>

    <script>
        var app = new Vue({
            el: '#app',
            data: {
                progress: 0
            },
            mounted() {
                const duration = 3000;//持续时长
                const interval = 30;//间隔时间
                
                const timer = setInterval(() => {
                    this.progress += 1;
                    if (this.progress >= 100) {
                        clearInterval(timer);
                    }
                }, interval);
            }
        });
    </script>
</body>

</html>